package com.dliu.javadesign.create.factory.normal;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 奖品发放
 * @author yanglei
 * date 2021/3/26 15:10
 */
@RestController
@Slf4j
public class AwardController {

    @PostMapping("/send2User")
    public ResponseVo<String> send2User(@RequestBody RequestVo requestVo){
        ResponseVo<String> responseVo = new ResponseVo<>();
        Integer type = requestVo.getType();
        switch (type){
            case 1: String s = sendCoupon(requestVo.getUserId()); break;
            case 2: boolean b = deliverGoods(requestVo.getAddr()); break;
            case 3: grantToken(requestVo.getTelephone());break;
        }
        responseVo.setCode(200);
        responseVo.setData("成功");
        return responseVo;
    }

    public String sendCoupon(Long uId){
        log.info("领取优惠券");
        return "领取优惠券";
    }

    public boolean deliverGoods(String addr){
        log.info("领取实物奖品");
        return !addr.equals("");
    }

    public void grantToken(String telephone){
        log.info("领取优酷会员");
    }
}
